class MyPage extends BaseList {
    constructor(orderby, flag, $pagesize, $pagination, listUrl, onLineEditUrl, checkBoxName) {
        super(orderby, flag, $pagesize, $pagination, listUrl, onLineEditUrl, checkBoxName);
    }
    GetFilter(pageIndex) {
        //let criterion = super.GetFilter(pageIndex);
        // 设置检索
        //return parseInt($.trim(parent.$("#MoHeaderId").val()));
        return JSON.stringify(parseInt($.trim(parent.$("#MoHeaderId").val())));
    }
    FetchAll() {
        this.FetchForPage(1);
    }
    EmptyTableContent() {
        $("#tabData01 tbody").empty();
    }
    SetTableContent(result) {
        $("#tabData01 tbody").empty();
        let content_01 = '';
        for (let i = 0; i < result.length; i++) {
            content_01 += '<tr>';
            content_01 += '<td style="padding-left:10px;"><label class="btn" for="R-' + result[i].linesId + '"><input id="R-' + result[i].linesId + '" name="_check_row" type="checkbox" onclick="_Instance.DoCheckRow($(this),$(\'#CheckAll\'));" value="' + result[i].linesId + '"/><i></i><span></span></label></td>';
            content_01 += '<td>' + result[i].destination + '</td>';
            content_01 += '</tr>';
            $("#tabData01 tbody").append(content_01);
            content_01 = '';
        }
        this.rows = result.length;
        this.numCheckbox = result.length;

        setOneTableRowColor("tabData01");
        this.AdjustDataTableHeight();

        $(window).resize();                     // 防止因为出现滚动条而造成画面显示问题
        $('#loading').hide();
    }
    // 设置行选择后的状态
    SetRowStatus($self) {
        super.AdjustRowStatus($self, ($row, index) => {
            let key = $self.val();
            this.selectedItemList[key] = $row.find("td").eq(1).text();
        }, ($row, index) => {
            let key = $self.val();
            delete this.selectedItemList[key];
        });
    }
    AdjustDataTableHeight() {
        let h = $(window).height();
        let _rc = Math.floor((h - ($("#tabHeader01").offset().top + 26) - 20) / 25);
        let _dh = _rc * 25;
        let _tah = this.rows * 25;
        _dh = (_tah >= _dh) ? _dh : _tah;

        $("#divD1").css({"max-height": _dh, height: _dh});
    }
}

let _Instance = null;

//-----------------------------------------------------------------------------
// 页面初始化
//-----------------------------------------------------------------------------
function onPageReady() {
    _Instance = new MyPage(null, 1, null, null,
            "/trade/production_instruction/lines/destination/fetch.html",
            "",
            "_check_row");

    _Instance.OnPageLoad();
}

// 画面大小或者位置移动
function onPageResize() {
    if (_Instance !== null)
        _Instance.AdjustDataTableHeight();
}